package srx.open.com.courseUtils;

import android.content.Context;

import com.google.gson.Gson;

import cn.bmob.v3.BmobPushManager;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.PushListener;
import srx.open.com.bean.User;

/**
 *  课程的订阅消息，状态改变.
 */
public class CourseManager {

    private static CourseManager courseManager;
    private Context mContext;

    public CourseManager getInstance(Context context) {
        mContext = context;
        if (courseManager == null) {
            synchronized (CourseManager.class) {
                if (courseManager == null)
                    courseManager = new CourseManager();
            }
        }
        return courseManager;
    }

    public void pubCourse(CourseMsg courseMsg) {
        BmobPushManager bmobPush = new BmobPushManager(mContext);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(courseMsg);
        BmobQuery<User> query =  new BmobQuery<User>();
        query.addWhereEqualTo("userName", "xxxxx");
        bmobPush.setQuery(query);
        bmobPush.pushMessage(jsonStr, new PushListener() {
            @Override
            public void onSuccess() {
            }

            @Override
            public void onFailure(int i, String s) {
            }
        });
    }
}
